#include <iostream>
using namespace std;

//void swap(int& x, int& y)
//{
//	int tmp = x;
//	x = y;
//	y = tmp;
//}
//
//void swap(double& x, double& y)
//{
//	double tmp = x;
//	x = y;
//	y = tmp;
//}

//template<class T>
//void Swap(T& x, T& y)
//{
//	T tmp = x;
//	x = y;
//	y = tmp;
//}
//
//template<class T1,class T2>
//void func1(const T1& x, const T2& y)
//{
//
//}
//int main()
//{
//	int x = 1, y = 6;
//	/*double n = 1.1, m = 5.3;
//	Swap(x, y);
//	func1(x, m);*/
//
//	swap(x, y);
//	return 0;
//}

//template<class T>
//T ADD(const T& x, const T& y)
//{
//	return x + y;
//}
//
//int main()
//{
//	int x = 10, y = 15;
//	double m = 1.1, n = 25.2;
//	ADD(x, y);
//	ADD(m, n);
//	ADD(x, (int)n);
//	ADD<int>(x, n);
//	return 0;
//}

template<class T>
class Stack
{
public:
	Stack(int capacity = 4)
		:_arr(new T[capacity])
		,_size(0)
		,_capacity(capacity)
	{}
	~Stack()
	{
		delete[] _arr;
		_arr = nullptr;
		_size = _capacity = 0;
	}
	void Push(const T& x)
	{
		if (_capacity == _size)
		{
			T* tmp = new T[_capacity * 2];
			memcpy(tmp, _arr, sizeof(T) * _size);
			delete _arr;
			_arr = tmp;
			_capacity *= 2;
		}
		_arr[_size++] = x;
	}
private:
	T* _arr;
	size_t _capacity;
	size_t _size;
};

int main()
{
	Stack<int> s1;
	s1.Push(1);
	s1.Push(1);
	s1.Push(1);

	Stack<double> s2;
	s2.Push(1.5);
	s2.Push(1.5);
	s2.Push(1.5);

	return 0;
}